<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>谷歌云 Compute Engine 安装 CentOS 7 总结 | AiKIKI</title><meta name="author" content="樵子"><meta name="copyright" content="樵子"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="referrer" content="no-referrer"><meta name="description" content="谷歌云再搞一年免费试用的活动，有兴趣的朋友可以网上查询一下申请教程。这里仅对谷歌云使用中的常见问题做一个总结。 创建谷歌云 CE 实例从以下功能位置进入谷歌云 CE 实例管理页面，按页面提示创建即可。  Google Cloud Platform &gt; Compute Engine &gt; VM 实例  设置静态 IP 和防火墙设置静态 IP 地址谷歌云 CE（Compute Engine）">
<meta property="og:type" content="article">
<meta property="og:title" content="谷歌云 Compute Engine 安装 CentOS 7 总结">
<meta property="og:url" content="https://www.aikiki.top/post/1952/index.html">
<meta property="og:site_name" content="AiKIKI">
<meta property="og:description" content="谷歌云再搞一年免费试用的活动，有兴趣的朋友可以网上查询一下申请教程。这里仅对谷歌云使用中的常见问题做一个总结。 创建谷歌云 CE 实例从以下功能位置进入谷歌云 CE 实例管理页面，按页面提示创建即可。  Google Cloud Platform &gt; Compute Engine &gt; VM 实例  设置静态 IP 和防火墙设置静态 IP 地址谷歌云 CE（Compute Engine）">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/acmeist/CDN/logos/centos-logo-horizontal.jfif">
<meta property="article:published_time" content="2019-05-27T16:40:00.000Z">
<meta property="article:modified_time" content="2023-11-16T08:34:17.000Z">
<meta property="article:author" content="樵子">
<meta property="article:tag" content="CentOS">
<meta property="article:tag" content="Google Cloud">
<meta property="article:tag" content="Compute Engine">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://cdn.jsdelivr.net/gh/acmeist/CDN/logos/centos-logo-horizontal.jfif"><link rel="shortcut icon" href="https://cdn.jsdelivr.net/gh/acmeist/CDN/www/img/favicon.ico"><link rel="canonical" href="https://www.aikiki.top/post/1952/index.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = {
  root: '/',
  algolia: undefined,
  localSearch: undefined,
  translate: {"defaultEncoding":2,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"簡"},
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  dateSuffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  infinitegrid: {
    js: 'https://cdn.jsdelivr.net/npm/@egjs/infinitegrid/dist/infinitegrid.min.js',
    buttonText: '加载更多'
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: false,
  },
  autoDarkmode: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: '谷歌云 Compute Engine 安装 CentOS 7 总结',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2023-11-16 16:34:17'
}</script><script>(win=>{
      win.saveToLocal = {
        set: (key, value, ttl) => {
          if (ttl === 0) return
          const now = Date.now()
          const expiry = now + ttl * 86400000
          const item = {
            value,
            expiry
          }
          localStorage.setItem(key, JSON.stringify(item))
        },
      
        get: key => {
          const itemStr = localStorage.getItem(key)
      
          if (!itemStr) {
            return undefined
          }
          const item = JSON.parse(itemStr)
          const now = Date.now()
      
          if (now > item.expiry) {
            localStorage.removeItem(key)
            return undefined
          }
          return item.value
        }
      }
    
      win.getScript = (url, attr = {}) => new Promise((resolve, reject) => {
        const script = document.createElement('script')
        script.src = url
        script.async = true
        script.onerror = reject
        script.onload = script.onreadystatechange = function() {
          const loadState = this.readyState
          if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
          script.onload = script.onreadystatechange = null
          resolve()
        }

        Object.keys(attr).forEach(key => {
          script.setAttribute(key, attr[key])
        })

        document.head.appendChild(script)
      })
    
      win.getCSS = (url, id = false) => new Promise((resolve, reject) => {
        const link = document.createElement('link')
        link.rel = 'stylesheet'
        link.href = url
        if (id) link.id = id
        link.onerror = reject
        link.onload = link.onreadystatechange = function() {
          const loadState = this.readyState
          if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
          link.onload = link.onreadystatechange = null
          resolve()
        }
        document.head.appendChild(link)
      })
    
      win.activateDarkMode = () => {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = () => {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
        if (t === 'dark') activateDarkMode()
        else if (t === 'light') activateLightMode()
      
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
      const detectApple = () => {
        if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
          document.documentElement.classList.add('apple')
        }
      }
      detectApple()
    })(window)</script><meta name="generator" content="Hexo 7.0.0"><link rel="alternate" href="/atom.xml" title="AiKIKI" type="application/atom+xml">
</head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="https://cdn.jsdelivr.net/gh/acmeist/CDN/www/img/avatar.png" onerror="onerror=null;src='https://cdn.jsdelivr.net/gh/acmeist/CDN/www/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">28</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">21</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">1</div></a></div><hr class="custom-hr"/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> Home</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> Archives</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> Tags</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> Categories</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> Link</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> About</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://cdn.jsdelivr.net/gh/acmeist/CDN/logos/centos-logo-horizontal.jfif')"><nav id="nav"><span id="blog-info"><a href="/" title="AiKIKI"><span class="site-name">AiKIKI</span></a></span><div id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> Home</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> Archives</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> Tags</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> Categories</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> Link</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> About</span></a></div></div><div id="toggle-menu"><a class="site-page" href="javascript:void(0);"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">谷歌云 Compute Engine 安装 CentOS 7 总结</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2019-05-27T16:40:00.000Z" title="发表于 2019-05-28 00:40:00">2019-05-28</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2023-11-16T08:34:17.000Z" title="更新于 2023-11-16 16:34:17">2023-11-16</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/Archives/">Archives</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">1.2k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>4分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="谷歌云 Compute Engine 安装 CentOS 7 总结"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><p>谷歌云再搞一年免费试用的活动，有兴趣的朋友可以网上查询一下申请教程。这里仅对谷歌云使用中的常见问题做一个总结。</p>
<h1 id="创建谷歌云-CE-实例"><a href="#创建谷歌云-CE-实例" class="headerlink" title="创建谷歌云 CE 实例"></a>创建谷歌云 CE 实例</h1><p>从以下功能位置进入谷歌云 CE 实例管理页面，按页面提示创建即可。</p>
<blockquote>
<p>Google Cloud Platform &gt; Compute Engine &gt; VM 实例</p>
</blockquote>
<h1 id="设置静态-IP-和防火墙"><a href="#设置静态-IP-和防火墙" class="headerlink" title="设置静态 IP 和防火墙"></a>设置静态 IP 和防火墙</h1><h2 id="设置静态-IP-地址"><a href="#设置静态-IP-地址" class="headerlink" title="设置静态 IP 地址"></a>设置静态 IP 地址</h2><p>谷歌云 CE（Compute Engine） 实例默认外部 IP 地址是<code>临时分配地址</code>，需要设置为<code>静态地址</code>。</p>
<p>设置方法很简单，在以下功能位置按提示设置即可。</p>
<blockquote>
<p>Google Cloud Platform &gt; VPC 网络 &gt; 外部 IP 地址</p>
</blockquote>
<h2 id="设置防火墙规则"><a href="#设置防火墙规则" class="headerlink" title="设置防火墙规则"></a>设置防火墙规则</h2><p>防火墙规则设置也在 <code>VPC 网络</code> 设置菜单下面，默认开启了常用规则。</p>
<blockquote>
<p>Google Cloud Platform &gt; VPC 网络 &gt; 防火墙规则</p>
</blockquote>
<h1 id="设置-SSH-登录方式为密码登录"><a href="#设置-SSH-登录方式为密码登录" class="headerlink" title="设置 SSH 登录方式为密码登录"></a>设置 SSH 登录方式为密码登录</h1><p>谷歌云 CE 默认不提供密码登录方式，为了使用方便需要更改为密码登录方式。</p>
<h2 id="登录谷歌云-CE-实例"><a href="#登录谷歌云-CE-实例" class="headerlink" title="登录谷歌云 CE 实例"></a>登录谷歌云 CE 实例</h2><p>从以下功能位置进入谷歌云 CE 实例</p>
<blockquote>
<p>Google Cloud Platform &gt; Compute Engine &gt; VM 实例</p>
</blockquote>
<p>点击相应 CE 实例后面的<code>SSH</code>下拉选项，选择<code>在浏览器窗口中打开</code>。</p>
<p>浏览器开新窗口自动完成 VM 实例登录。</p>
<h2 id="修改-SSH-配置文件"><a href="#修改-SSH-配置文件" class="headerlink" title="修改 SSH 配置文件"></a>修改 SSH 配置文件</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"># 切换到 root 用户</span><br><span class="line">sudo -i</span><br><span class="line"></span><br><span class="line"># 修改 ssh 配置文件</span><br><span class="line">vim /etc/ssh/sshd_config</span><br></pre></td></tr></table></figure>

<p>按以下说明修改代码：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"># 允许 Root 用户远程登录</span><br><span class="line">PermitRootLogin = yes</span><br><span class="line"></span><br><span class="line"># 允许密码授权</span><br><span class="line">PasswordAuthentication = yes</span><br></pre></td></tr></table></figure>

<h2 id="给-root-用户设置密码"><a href="#给-root-用户设置密码" class="headerlink" title="给 root 用户设置密码"></a>给 root 用户设置密码</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">passwd root</span><br></pre></td></tr></table></figure>

<h2 id="重启-SSH-服务使修改生效"><a href="#重启-SSH-服务使修改生效" class="headerlink" title="重启 SSH 服务使修改生效"></a>重启 SSH 服务使修改生效</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"># 以 CentOS 7 为例</span><br><span class="line">systemctl restart sshd</span><br></pre></td></tr></table></figure>

<p>现在可以再 xshell 中，直接使用 root 账号和密码登录。</p>
<h1 id="配置-CentOS-7-第三方源"><a href="#配置-CentOS-7-第三方源" class="headerlink" title="配置 CentOS 7 第三方源"></a>配置 CentOS 7 第三方源</h1><p>谷歌云默认 VM 实例安装的 CentOS 和阿里云、腾讯云不同，自带源缺少一些常用软件。因此需要配置第三方源。</p>
<h2 id="下载第三方源"><a href="#下载第三方源" class="headerlink" title="下载第三方源"></a>下载第三方源</h2><p>点击 <a target="_blank" rel="noopener" href="http://repoforge.org/use/">这里</a> 进入第三方源网站，选择下载适合自己的源。</p>
<p>我下载的是：EL 7: <a target="_blank" rel="noopener" href="http://repository.it4i.cz/mirrors/repoforge/redhat/el7/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm">x86_64</a></p>
<h2 id="安装第三方源"><a href="#安装第三方源" class="headerlink" title="安装第三方源"></a>安装第三方源</h2><p>谷歌云默认实例没有 wget，因此需要将该文件上传到服务器手动安装。</p>
<blockquote>
<p>使用 WinSCP 上传下载文件。</p>
</blockquote>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 安装 rpm 包</span></span><br><span class="line">rpm -ivh 包名</span><br><span class="line"></span><br><span class="line"><span class="comment"># 确认是否添加成功。该目录下是否新增了rpmforge.repo文件，如果有说明添加成功。</span></span><br><span class="line"><span class="built_in">ls</span> /etc/yum.repos.d/</span><br><span class="line">CentOS-Base.bak.repo  CentOS-Debuginfo.repo  CentOS-Sources.repo  epel-testing.repo  mirrors-rpmforge-extras</span><br><span class="line">CentOS-Base.repo      CentOS-fasttrack.repo  CentOS-Vault.repo    google-cloud.repo  mirrors-rpmforge-testing</span><br><span class="line">CentOS-CR.repo        CentOS-Media.repo      epel.repo            mirrors-rpmforge   rpmforge.repo</span><br></pre></td></tr></table></figure>

<h2 id="安装-wget-测试源"><a href="#安装-wget-测试源" class="headerlink" title="安装 wget 测试源"></a>安装 wget 测试源</h2><p>现在可以安装 wget 了。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum -y install wget</span><br></pre></td></tr></table></figure>

<h1 id="禁止-root-用户远程登录和修改-ssh-端口"><a href="#禁止-root-用户远程登录和修改-ssh-端口" class="headerlink" title="禁止 root 用户远程登录和修改 ssh 端口"></a>禁止 root 用户远程登录和修改 ssh 端口</h1><p>为了系统安全，建议禁止 root 用户远程登录。</p>
<h2 id="创建用户和密码"><a href="#创建用户和密码" class="headerlink" title="创建用户和密码"></a>创建用户和密码</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"># 创建新用户</span><br><span class="line">useradd aikiki</span><br><span class="line"></span><br><span class="line"># 修改新用户密码</span><br><span class="line">passwd aikiki</span><br></pre></td></tr></table></figure>

<blockquote>
<p>新用户创建成功后，建议注销系统后重新用新用户登录。以便测试新用户创建的正确性。</p>
</blockquote>
<h2 id="修改-sshd-配置文件"><a href="#修改-sshd-配置文件" class="headerlink" title="修改 sshd 配置文件"></a>修改 sshd 配置文件</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"># 切换到 root 用户</span><br><span class="line">su -</span><br><span class="line"></span><br><span class="line"># 编辑 sshd 配置文件</span><br><span class="line">vim /etc/ssh/sshd_config</span><br></pre></td></tr></table></figure>

<p>修改以下配置：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"># 关闭 Root 用户远程登录</span><br><span class="line">PermitRootLogin false</span><br><span class="line"></span><br><span class="line"># 将默认端口修改为任意端口（可以设置数字建议1000-60000,尽量的不要与其他项目冲突。）。</span><br><span class="line">Port  22</span><br></pre></td></tr></table></figure>

<blockquote>
<p>建议不要修改 22 端口，而是使用防火墙限制 22 端口的可访问 IP 地址。如果是 CentOS 7 系统修改了 SSH 端口，还需要配置 SELinux 打开修改后的端口或是关闭 SELinux。</p>
</blockquote>
<h2 id="重启-sshd-服务"><a href="#重启-sshd-服务" class="headerlink" title="重启 sshd 服务"></a>重启 sshd 服务</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">systemctl restart sshd</span><br></pre></td></tr></table></figure>

<h1 id="搭建服务器"><a href="#搭建服务器" class="headerlink" title="搭建服务器"></a>搭建服务器</h1><p>一键搭建脚本:</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">wget -N --no-check-certificate https://raw.githubusercontent.com/ToyoDAdoubi/doubi/master/ssr.sh &amp;&amp; <span class="built_in">chmod</span> +x ssr.sh &amp;&amp; bash ssr.sh</span><br></pre></td></tr></table></figure>

<p>该安装脚本为中文提示信息，这里就不多做说明，只说明几个关键点：</p>
<ul>
<li>加密方式选择：<code>10 aes-256-cfb</code></li>
<li>协议插件选择：<code>2 auth_shal-v4</code></li>
<li>协议插件兼容原版选择：<code>y</code></li>
<li>混淆插件选择：<code>1 plain</code></li>
</ul>
<p>安装完成后会出现安装信息提示，需要设置到客户端。</p>
<p>附客户端一键安装：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"># 该脚本会运行 git 命令，所以需提先安装 git。</span><br><span class="line">sudo apt-get install git</span><br><span class="line"></span><br><span class="line"># 下载和安装脚本</span><br><span class="line">wget http://www.djangoz.com/ssr</span><br><span class="line">sudo mv ssr /usr/local/bin</span><br><span class="line">sudo chmod 766 /usr/local/bin/ssr</span><br><span class="line"></span><br><span class="line"># 安装</span><br><span class="line">ssr install</span><br><span class="line"></span><br><span class="line"># 配置</span><br><span class="line">ssr config</span><br></pre></td></tr></table></figure>

<blockquote>
<p><a target="_blank" rel="noopener" href="https://github.com/the0demiurge/CharlesScripts/blob/master/charles/bin/ssr">一键安装脚本 git 地址</a></p>
</blockquote>
<p>编辑 rc.local 文件增加自启动命令：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo vim /etc/rc.local</span><br></pre></td></tr></table></figure>

<p>在配置文件末尾增加启动命令:</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#!/bin/sh -e</span></span><br><span class="line"><span class="comment">#</span></span><br><span class="line"><span class="comment"># rc.local</span></span><br><span class="line"><span class="comment">#</span></span><br><span class="line"><span class="comment"># This script is executed at the end of each multiuser runlevel.</span></span><br><span class="line"><span class="comment"># Make sure that the script will &quot;exit 0&quot; on success or any other</span></span><br><span class="line"><span class="comment"># value on error.</span></span><br><span class="line"><span class="comment">#</span></span><br><span class="line"><span class="comment"># In order to enable or disable this script just change the execution</span></span><br><span class="line"><span class="comment"># bits.</span></span><br><span class="line"><span class="comment">#</span></span><br><span class="line"><span class="comment"># By default this script does nothing.</span></span><br><span class="line">sudo ssr start</span><br><span class="line"><span class="built_in">exit</span> 0</span><br></pre></td></tr></table></figure>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta"><i class="fas fa-circle-user fa-fw"></i>文章作者: </span><span class="post-copyright-info"><a href="https://www.aikiki.top">樵子</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta"><i class="fas fa-square-arrow-up-right fa-fw"></i>文章链接: </span><span class="post-copyright-info"><a href="https://www.aikiki.top/post/1952/">https://www.aikiki.top/post/1952/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta"><i class="fas fa-circle-exclamation fa-fw"></i>版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://www.aikiki.top" target="_blank">AiKIKI</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/CentOS/">CentOS</a><a class="post-meta__tags" href="/tags/Google-Cloud/">Google Cloud</a><a class="post-meta__tags" href="/tags/Compute-Engine/">Compute Engine</a></div><div class="post_share"><div class="social-share" data-image="https://cdn.jsdelivr.net/gh/acmeist/CDN/logos/centos-logo-horizontal.jfif" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/post/dab6/" title="使用 Windows 自带的远程桌面 mstsc 连接 CentOS 7"><img class="cover" src="https://cdn.jsdelivr.net/gh/acmeist/CDN/logos/centos-logo-horizontal.jfif" onerror="onerror=null;src='https://cdn.jsdelivr.net/gh/acmeist/CDN/www/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">使用 Windows 自带的远程桌面 mstsc 连接 CentOS 7</div></div></a></div><div class="next-post pull-right"><a href="/post/52e3/" title="CentOS 7 搭建 LNMP 环境"><img class="cover" src="https://cdn.jsdelivr.net/gh/acmeist/CDN/logos/centos-logo-horizontal.jfif" onerror="onerror=null;src='https://cdn.jsdelivr.net/gh/acmeist/CDN/www/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">CentOS 7 搭建 LNMP 环境</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><div><a href="/post/e4e5/" title="CentOS 7 搭建 LAMP 环境安装 WordPress"><img class="cover" src="https://cdn.jsdelivr.net/gh/acmeist/CDN/logos/centos-logo-horizontal.jfif" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2019-05-10</div><div class="title">CentOS 7 搭建 LAMP 环境安装 WordPress</div></div></a></div><div><a href="/post/52e3/" title="CentOS 7 搭建 LNMP 环境"><img class="cover" src="https://cdn.jsdelivr.net/gh/acmeist/CDN/logos/centos-logo-horizontal.jfif" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2019-05-26</div><div class="title">CentOS 7 搭建 LNMP 环境</div></div></a></div><div><a href="/post/dab6/" title="使用 Windows 自带的远程桌面 mstsc 连接 CentOS 7"><img class="cover" src="https://cdn.jsdelivr.net/gh/acmeist/CDN/logos/centos-logo-horizontal.jfif" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2019-06-20</div><div class="title">使用 Windows 自带的远程桌面 mstsc 连接 CentOS 7</div></div></a></div><div><a href="/post/a3e5/" title="CentOS 7 清理开机启动项"><img class="cover" src="https://cdn.jsdelivr.net/gh/acmeist/CDN/logos/centos-logo-horizontal.jfif" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2020-03-14</div><div class="title">CentOS 7 清理开机启动项</div></div></a></div><div><a href="/post/def6/" title="使用 Windows 自带的远程桌面 mstsc 连接 CentOS 8"><img class="cover" src="https://cdn.jsdelivr.net/gh/acmeist/CDN/logos/centos-logo-horizontal.jfif" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2020-05-09</div><div class="title">使用 Windows 自带的远程桌面 mstsc 连接 CentOS 8</div></div></a></div><div><a href="/post/ea01/" title="CentOS 8 安装 Docker-CE"><img class="cover" src="https://cdn.jsdelivr.net/gh/acmeist/CDN/logos/centos-logo-horizontal.jfif" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-03-23</div><div class="title">CentOS 8 安装 Docker-CE</div></div></a></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="https://cdn.jsdelivr.net/gh/acmeist/CDN/www/img/avatar.png" onerror="this.onerror=null;this.src='https://cdn.jsdelivr.net/gh/acmeist/CDN/www/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">樵子</div><div class="author-info__description">Always CREATIVE.</div></div><div class="card-info-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">28</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">21</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">1</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/acmeist"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/acmeist" target="_blank" title="Github"><i class="fab fa-github" style="color: #24292e;"></i></a><a class="social-icon" href="mailto:huweighost@gmail.com" target="_blank" title="Email"><i class="fas fa-envelope" style="color: #4a7dbe;"></i></a><a class="social-icon" href="/atom.xml" target="_blank" title="Rss"><i class="fas fa-rss"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">感謝訪問本站，若喜歡請收藏 ^_^</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%88%9B%E5%BB%BA%E8%B0%B7%E6%AD%8C%E4%BA%91-CE-%E5%AE%9E%E4%BE%8B"><span class="toc-number">1.</span> <span class="toc-text">创建谷歌云 CE 实例</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E8%AE%BE%E7%BD%AE%E9%9D%99%E6%80%81-IP-%E5%92%8C%E9%98%B2%E7%81%AB%E5%A2%99"><span class="toc-number">2.</span> <span class="toc-text">设置静态 IP 和防火墙</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E8%AE%BE%E7%BD%AE%E9%9D%99%E6%80%81-IP-%E5%9C%B0%E5%9D%80"><span class="toc-number">2.1.</span> <span class="toc-text">设置静态 IP 地址</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E8%AE%BE%E7%BD%AE%E9%98%B2%E7%81%AB%E5%A2%99%E8%A7%84%E5%88%99"><span class="toc-number">2.2.</span> <span class="toc-text">设置防火墙规则</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E8%AE%BE%E7%BD%AE-SSH-%E7%99%BB%E5%BD%95%E6%96%B9%E5%BC%8F%E4%B8%BA%E5%AF%86%E7%A0%81%E7%99%BB%E5%BD%95"><span class="toc-number">3.</span> <span class="toc-text">设置 SSH 登录方式为密码登录</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%99%BB%E5%BD%95%E8%B0%B7%E6%AD%8C%E4%BA%91-CE-%E5%AE%9E%E4%BE%8B"><span class="toc-number">3.1.</span> <span class="toc-text">登录谷歌云 CE 实例</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%BF%AE%E6%94%B9-SSH-%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6"><span class="toc-number">3.2.</span> <span class="toc-text">修改 SSH 配置文件</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%BB%99-root-%E7%94%A8%E6%88%B7%E8%AE%BE%E7%BD%AE%E5%AF%86%E7%A0%81"><span class="toc-number">3.3.</span> <span class="toc-text">给 root 用户设置密码</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E9%87%8D%E5%90%AF-SSH-%E6%9C%8D%E5%8A%A1%E4%BD%BF%E4%BF%AE%E6%94%B9%E7%94%9F%E6%95%88"><span class="toc-number">3.4.</span> <span class="toc-text">重启 SSH 服务使修改生效</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E9%85%8D%E7%BD%AE-CentOS-7-%E7%AC%AC%E4%B8%89%E6%96%B9%E6%BA%90"><span class="toc-number">4.</span> <span class="toc-text">配置 CentOS 7 第三方源</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%B8%8B%E8%BD%BD%E7%AC%AC%E4%B8%89%E6%96%B9%E6%BA%90"><span class="toc-number">4.1.</span> <span class="toc-text">下载第三方源</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%AE%89%E8%A3%85%E7%AC%AC%E4%B8%89%E6%96%B9%E6%BA%90"><span class="toc-number">4.2.</span> <span class="toc-text">安装第三方源</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%AE%89%E8%A3%85-wget-%E6%B5%8B%E8%AF%95%E6%BA%90"><span class="toc-number">4.3.</span> <span class="toc-text">安装 wget 测试源</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E7%A6%81%E6%AD%A2-root-%E7%94%A8%E6%88%B7%E8%BF%9C%E7%A8%8B%E7%99%BB%E5%BD%95%E5%92%8C%E4%BF%AE%E6%94%B9-ssh-%E7%AB%AF%E5%8F%A3"><span class="toc-number">5.</span> <span class="toc-text">禁止 root 用户远程登录和修改 ssh 端口</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%88%9B%E5%BB%BA%E7%94%A8%E6%88%B7%E5%92%8C%E5%AF%86%E7%A0%81"><span class="toc-number">5.1.</span> <span class="toc-text">创建用户和密码</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%BF%AE%E6%94%B9-sshd-%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6"><span class="toc-number">5.2.</span> <span class="toc-text">修改 sshd 配置文件</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E9%87%8D%E5%90%AF-sshd-%E6%9C%8D%E5%8A%A1"><span class="toc-number">5.3.</span> <span class="toc-text">重启 sshd 服务</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E6%90%AD%E5%BB%BA%E6%9C%8D%E5%8A%A1%E5%99%A8"><span class="toc-number">6.</span> <span class="toc-text">搭建服务器</span></a></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/post/c3b4/" title="Docker 使用宿主机网段"><img src="https://cdn.jsdelivr.net/gh/acmeist/CDN/logos/docker-logo-horizontal.jfif" onerror="this.onerror=null;this.src='https://cdn.jsdelivr.net/gh/acmeist/CDN/www/img/404.jpg'" alt="Docker 使用宿主机网段"/></a><div class="content"><a class="title" href="/post/c3b4/" title="Docker 使用宿主机网段">Docker 使用宿主机网段</a><time datetime="2023-12-18T01:27:00.000Z" title="发表于 2023-12-18 09:27:00">2023-12-18</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/post/1e36/" title="ESXi 远程 SSH 终端登录显示器管理界面"><img src="https://cdn.jsdelivr.net/gh/acmeist/CDN/logos/esxi-logo-horizontal.jfif" onerror="this.onerror=null;this.src='https://cdn.jsdelivr.net/gh/acmeist/CDN/www/img/404.jpg'" alt="ESXi 远程 SSH 终端登录显示器管理界面"/></a><div class="content"><a class="title" href="/post/1e36/" title="ESXi 远程 SSH 终端登录显示器管理界面">ESXi 远程 SSH 终端登录显示器管理界面</a><time datetime="2023-11-29T01:45:00.000Z" title="发表于 2023-11-29 09:45:00">2023-11-29</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/post/9973/" title="ESXi 6.7 自动关机设置"><img src="https://cdn.jsdelivr.net/gh/acmeist/CDN/logos/esxi-logo-horizontal.jfif" onerror="this.onerror=null;this.src='https://cdn.jsdelivr.net/gh/acmeist/CDN/www/img/404.jpg'" alt="ESXi 6.7 自动关机设置"/></a><div class="content"><a class="title" href="/post/9973/" title="ESXi 6.7 自动关机设置">ESXi 6.7 自动关机设置</a><time datetime="2023-11-25T07:12:00.000Z" title="发表于 2023-11-25 15:12:00">2023-11-25</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/post/bf0c/" title="OpenWrt 安装自带 Tailscale 和 ZeroTier"><img src="https://cdn.jsdelivr.net/gh/acmeist/CDN/logos/openwrt-logo-horizontal.jfif" onerror="this.onerror=null;this.src='https://cdn.jsdelivr.net/gh/acmeist/CDN/www/img/404.jpg'" alt="OpenWrt 安装自带 Tailscale 和 ZeroTier"/></a><div class="content"><a class="title" href="/post/bf0c/" title="OpenWrt 安装自带 Tailscale 和 ZeroTier">OpenWrt 安装自带 Tailscale 和 ZeroTier</a><time datetime="2023-11-21T01:19:00.000Z" title="发表于 2023-11-21 09:19:00">2023-11-21</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/post/53a7/" title="OpenWrt 更新所有已安装软件包"><img src="https://cdn.jsdelivr.net/gh/acmeist/CDN/logos/openwrt-logo-horizontal.jfif" onerror="this.onerror=null;this.src='https://cdn.jsdelivr.net/gh/acmeist/CDN/www/img/404.jpg'" alt="OpenWrt 更新所有已安装软件包"/></a><div class="content"><a class="title" href="/post/53a7/" title="OpenWrt 更新所有已安装软件包">OpenWrt 更新所有已安装软件包</a><time datetime="2023-11-15T01:38:00.000Z" title="发表于 2023-11-15 09:38:00">2023-11-15</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2023 By 樵子</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div><div class="footer_custom_text"><a target="_blank" rel="noopener" href="https://beian.miit.gov.cn/"><img class="icp-icon" src="https://cdn.jsdelivr.net/gh/acmeist/CDN/www/img/icp.png"><span>渝ICP备19007019号</span></a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="translateLink" type="button" title="简繁转换">繁</button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside-config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="/js/tw_cn.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.umd.min.js"></script><div class="js-pjax"></div><script defer="defer" id="fluttering_ribbon" mobile="false" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/canvas-fluttering-ribbon.min.js"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>